package com.guigu.qingcheng.client;

import com.guigu.qingcheng.pojo.TbOrderItem;
import com.guigu.qingcheng.pojo.vo.SkuGoodsVo;
import com.guigu.qingcheng.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 远程调用商品模块
 */
@FeignClient(name="service-goods")
@Component
public interface GoodsClient {

    /**
     * 根据商品id查找商品
     * @param id
     * @return
     */
    @GetMapping("/goods/goods/queryByGoodsName/{id}")
    public R queryByGoodsName(@PathVariable("id") String id);


    /**
     * 根据商品名称查找商品  不分页
     * @param name
     * @return
     */
    @GetMapping("/goods/goods/queryByGoodsLikeName/{name}")
    public R queryByGoodsLikeName(@PathVariable("name") String name);


    /**
     * 根据id获取信息 只查询name
     * @param id
     * @return
     */
    @GetMapping("/goods/category/detailname/{id}")
    public R detailname(@PathVariable("id") Integer id);


    /**
     * 扣减库存
     * @param list
     * @return
     */
    @PostMapping("/goods/sku/deductionStock")
    public boolean deductionStock(@RequestBody List<TbOrderItem> list);


    /**
     * 添加库存
     * @param list
     * @return
     */
    @PostMapping("/goods/sku/deductionStock2")
    public boolean deductionStock2(@RequestBody List<TbOrderItem> list);


    @PostMapping("/goods/goods/querySkuGoodsBySpec")
    public String querySkuGoodsBySpec(@RequestBody SkuGoodsVo skuGoodsVo);
}
